package com.gotoxoyo.demo.service;

import org.springframework.stereotype.Service;
import org.springframework.web.servlet.ModelAndView;

@Service
public class LoginService {

	public ModelAndView doLogin(String loginUrl, String successUrl, String uname, String upasswd) {
		if (uname == null || "".equals(uname)) {
			return new ModelAndView(loginUrl, "error", "用户名不能为空");
		} 
		
		if (upasswd == null || "".equals(upasswd)) {
			return new ModelAndView(loginUrl, "error", "密码不能为空");
		} 
		
		if (uname.equals("admin") && upasswd.equals("123")) {
			return new ModelAndView(successUrl);
		} else {
			return new ModelAndView(loginUrl, "error", "用户名或密码错误");
		}
		
	}
}
